﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TimeTracker.Provider
{
    public static class IEnumerableIProjectExtensions
    {
        public static TimeSpan Duration(this IEnumerable<IProject> container)
        {
            return new TimeSpan(container.Sum(s => s.Duration().Ticks));
        }

        public static TimeSpan Duration(this IEnumerable<IProject> container, DateTime day)
        {
            return new TimeSpan(container.Sum(r => r.Duration(day).Ticks));
        }

        public static bool IsArchived(this IEnumerable<IProject> container)
        {
            return container.All(r => r.IsArchived());
        }

        public static bool IsArchived(this IEnumerable<IProject> container, DateTime day)
        {
            return container.All(r => r.IsArchived(day));
        }
    }
}
